#1、有这样的一个列表，深度不可知，列表里面还会嵌套列表，我想要把这个列表从左到右拼接成一个新的列表，且顺序不变
#举例：[12,33,[11,22,33,[55,66,99]],[55,66]]
#变成：[12, 33, 11, 22, 33, 55, 66, 99, 55, 66]
"""
def a(zy):
    biao = []
    for i in zy:
        if type(i) == list:
            biao.extend(a(i))
        else:
            biao.append(i)
    return biao
zy = [12, 33, [11, 22, 33, [55, 66, 99]], [55, 66]]
j = a(zy)
print(j)
"""
#2、编写装饰器，为多个函数加上认证的功能（用户的账号密码） 要求登录成功一次，后续的函数都无需输入用户名和密码
"""
a = {'username': 'user123', 'password': 'pass123'}
def b(func):
    def c(*args, **kwargs):
        username = input("请输入用户名: ")
        password = input("请输入密码: ")
        if username == a['username'] and password == a['password']:
            return func(*args, **kwargs)
        else:
            print("认证失败，请检查用户名和密码")
    return c
@b
def d():
    print("登陆成功")
d()
"""
#3、请实现一个装饰器，把函数的返回值+100然后返回
"""
a = int(1)
b= a+100
print(b)
"""
"""
def con(a):
    b=a+100
    return b
print(con(1))
"""
"""
def con(a):
    def luoji(s):
        a(s)
        b = s+100
        return b
    return luoji
@con
def func(s):
   return s
print(func(1156))
"""
#4、请实现一个装饰器，通过一次调用使函数重复执行5次
"""
a=[1,2,3,4,5]
for i in range(5):
    print(a)
"""
"""
def con(a):
    for i in range(5):
        print(a)
con([1,2,3,4,5])
"""
"""
def con(a):
    def func(s):
        a(s)
        for i in range(5):
            print(s)
    return func
@con
def c(cc):
    return cc
c([1,2,3,4,5])
"""
#5、输入任意个字符串,分别实现从小到大输出和从大到小输出
"""
a = ["sas","sakjfsjk","hf"]
b = sorted(a,key=len,reverse=True)
c = sorted(a,key=len)
print(f"从大到小是{b}, 从小到大是{c}")
"""
"""
def con(a):
    b = sorted(a, key=len, reverse=True)
    c = sorted(a,key=len)
    print(f"从大到小是{b}, 从小到大是{c}")
con(["sas","sakjfsjk","hf"])
"""
"""
def con(a):
    def func(i):
        a(i)
        b = sorted(i, key=len, reverse=True)
        c = sorted(i, key=len)
        print(f"从大到小是{b}, 从小到大是{c}")
    return func
@con
def cc(z):
    pass
cc(["sas","sakjfsjk","hf"])
"""
#6、接收n个数字，求这些参数数字的和
"""
a= [55,66,88,9999,545]
b=sum(a)
print(b)
"""
"""
def con(a):
    b=sum(a)
    print(b)
con([55,66,88,9999,545])
"""
"""
def con(a):
    def func(z):
        a(z)
        b=sum(z)
        print(b)
    return func
@con
def sum1(s):
    pass
sum1([5,6,7,8,9,10])
"""
#7、编写一个函数，实现数字的自增（从0开始，每调用一次，数字+1）
"""
a=0
def  jia():
    def jia_1():
        global a
        a+=1
        return a
    return jia_1
print(jia()())
print(jia()())
print(jia()())
print(jia()())
"""
